:root {
    --bg: #f7f8fc;
    --card: #ffffff;
    --muted: #667085;
    --accent: #6c63ff;
    --high: #ef4444;
    --low: #10b981;
    --glass: rgba(255, 255, 255, 0.6);
    --radius: 12px;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
    --transition: 0.25s ease;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    margin: 0;
    background: linear-gradient(180deg, #f8faff, #eef1ff);
    color: #0f172a;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.app {
    width: 100%;
    max-width: 1100px;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.brand h1 span {
    color: var(--accent);
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.top-actions button {
    background: transparent;
    border: 0;
    padding: 8px 10px;
    font-size: 1rem;
    cursor: pointer;
    color: var(--muted);
    border-radius: 8px;
    transition: background var(--transition);
}

.top-actions button:hover {
    background: var(--glass);
}

.panel {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.composer {
    background: var(--card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

#todoForm {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#todoText,
#todoDue,
#todoPriority {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #e6e9f2;
    font-size: 0.95rem;
    transition: border var(--transition);
}

#todoText {
    flex: 1;
    min-width: 180px;
}

#todoText:focus,
#todoDue:focus,
#todoPriority:focus {
    border-color: var(--accent);
}

#addBtn {
    background: var(--accent);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    border: 0;
    cursor: pointer;
    font-weight: 500;
    transition: background var(--transition), transform var(--transition);
}

#addBtn:hover {
    background: #5b54e5;
    transform: scale(1.04);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    align-items: center;
}

#search {
    flex: 1;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid #e6e9f2;
}

.filters {
    display: flex;
    gap: 8px;
}

.filters button {
    background: transparent;
    border: 1px solid #e6e9f2;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #334155;
    transition: all var(--transition);
}

.filters button.active,
.filters button:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.list-area {
    background: var(--card);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 10px;
}

#progressWrap {
    background: #eef2ff;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

#progressBar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    transition: width 0.4s ease;
}

.todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #fff, #f9faff);
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid #eef1ff;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.todo-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.06);
}

.left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid #dbe6ff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background var(--transition), border var(--transition);
}

.checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.text .title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
}

.meta {
    font-size: 12px;
    color: var(--muted);
}

.badge {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.badge.high {
    background: #fff1f0;
    color: var(--high);
    border: 1px solid rgba(239, 68, 68, 0.06);
}

.badge.low {
    background: #ecfdf5;
    color: var(--low);
    border: 1px solid rgba(16, 185, 129, 0.06);
}

.badge.normal {
    background: #f8fafc;
    color: #334155;
    border: 1px solid rgba(51, 65, 85, 0.04);
}

.right {
    display: flex;
    gap: 6px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: 0;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
    background: var(--glass);
    color: var(--accent);
}

.analytics {
    background: var(--card);
    padding: 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.analytics h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

#chartMini p {
    margin: 6px 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.bottom-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
    gap: 10px;
}

.bottom-actions button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e6e9f2;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.bottom-actions button:hover {
    background: #f8f9ff;
    border-color: var(--accent);
    color: var(--accent);
}

:focus {
    outline: 3px solid rgba(108, 99, 255, 0.2);
    outline-offset: 3px;
}

@media (max-width: 1024px) {
    .panel {
        grid-template-columns: 1fr 280px;
    }
}

@media (max-width: 900px) {
    .panel {
        grid-template-columns: 1fr;
    }
    .analytics {
        order: 3;
    }
    .list-area {
        order: 2;
    }
    .composer {
        order: 1;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .app {
        margin-top: 10px;
    }
    .brand h1 {
        font-size: 1.25rem;
    }
    #todoText {
        flex: 1 1 100%;
    }
    .todo-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .right {
        margin-top: 6px;
    }
}

body.dark {
    --bg: #111827;
    --card: #1f2937;
    --muted: #94a3b8;
    --accent: #8b5cf6;
    --high: #f87171;
    --low: #34d399;
    --glass: rgba(255, 255, 255, 0.08);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    background: linear-gradient(180deg, #0f172a, #1e293b);
    color: #e2e8f0;
}

body.dark .top-actions button:hover,
body.dark .icon-btn:hover {
    background: var(--glass);
}

body.dark .filters button.active,
body.dark #addBtn {
    background: var(--accent);
    color: #fff;
}

body.dark .list-area,
body.dark .composer,
body.dark .analytics {
    background: var(--card);
    box-shadow: var(--shadow);
}

body.dark #progressWrap {
    background: #334155;
}

@media (max-width: 480px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .top-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }
    #todoText {
        flex: 1 1 100%;
    }
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--card);
    color: #0f172a;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(150%);
    opacity: 0;
    transition: all 0.4s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    border-left: 5px solid #22c55e;
}

.toast.error {
    border-left: 5px solid #ef4444;
}

.toast.info {
    border-left: 5px solid var(--accent);
}

body.dark .toast {
    background: #1e293b;
    color: #f8fafc;
}
